from typing import List


class Solution:
    def incremovableSubarrayCount(self, nums: List[int]) -> int:

        n = len(nums)
        right_bound = [0] * n
        total_length = 0

        right_bound[n - 1] = n - 1
        for i in range(n - 2, -1, -1):
            if nums[i] < nums[i + 1]:
                right_bound[i] = right_bound[i + 1]
            else:
                right_bound[i] = i

        last_value = None
        for i in range(n):
            if nums[i] != last_value:
                total_length += right_bound[i] - i + 1
            last_value = nums[i]

        return total_length

# 生成incremovableSubarrayCount测试用例

print(Solution().incremovableSubarrayCount([8,7,6,6]))  # 输出: 4
